package util;

import java.util.ArrayList;
import java.util.HashSet;

import primatives.Vector;

import delaunay_triangulation.Point_dt;

public class GeoVertex extends Point_dt
{	
	protected int peak_number; // number of neighbours this vertex is greater than
	protected double peak_ratio; // ratio between neighbours.size() and peak_number
	
	public double curvatureMean;
	public double curvatureMeanAveraged;
	public double curvatureAnisotropic;
	public double curvatureAnisotropicAveraged;
	public double curvatureGaussian;
	
	public double curvatureRoughness;
	
	public double curvatureAvgRing;
	
	public double avgStrike;
	public double avgDip;

	// contains a list of x,y,z locations which represent a level of smoothness
	// the intent here is to have index 0 be the first level and it goes up to the size of this list
	// when rendering one simply switches indices of the smoothness
	private ArrayList<GeoVertex> smoothness;

	private float[] normal; // normal for this vertex, use for per vertex lighting and so on
	
	// these hash sets contain the indices to the triangle and vertex arrays found in DelaunayMapping
	public HashSet<Integer> trianglekeys;
	public HashSet<Integer> neighbourkeys;
	
	public int id;
	
	public double[] principle_curvatures;
	
	public GeoVertex()
	{
		super();
	}
	
	public GeoVertex(Point_dt p)
	{
		super(p);
		init();
	}
	
	public GeoVertex(double x, double y, double z)
	{
		super(x, y, z);
		init();
	}
	
	private void init()
	{
		id = -1;
		peak_number = 0;
		peak_ratio = 0.0;
		
		curvatureMean = 0.0;
		curvatureMeanAveraged = 0.0;
		curvatureGaussian = 0.0;
		curvatureAnisotropic = 0.0;
		curvatureAnisotropicAveraged = 0.0;
		curvatureRoughness = 0.0;
		
		curvatureAvgRing = 0.0;
		
		avgStrike = 0.0;
		avgDip = 0.0;
		
		trianglekeys = new HashSet<Integer>();
		neighbourkeys = new HashSet<Integer>();

		smoothness = null;
		normal = null;
		principle_curvatures = new double[2];
	}

	public void addLOSVertex(GeoVertex gv)
	{
		if (smoothness == null) smoothness = new ArrayList<GeoVertex>();
		smoothness.add(gv);
	}
	public GeoVertex getLOSVertex(int i) { return smoothness.get(i); }
	public GeoVertex getSmoothestVertex() { return smoothness.get(smoothness.size()-1); }
	public void clearSmoothedVertices() // reset the smoothness vertices so that we can re-smooth the mesh
	{
		if (smoothness != null)
			smoothness.clear();
	}
	
	public void setNormal(float[] n) { normal = n; }
	public float[] geNormal() { return normal; }

	public String getStringKey() { return this.x()+","+this.y()+","+this.z(); }
	
	public void setPeaks(int n)
	{
		peak_number = n;
		peak_ratio = (peak_number*1.0)/neighbourkeys.size();
	}
	
	public double getPeakRatio() { return peak_ratio; }

	public boolean equals(Object o)
	{
		return super.equals(o);
	}

}
